home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / doom / qplus10.zip / ITEMS.QC < prev    next >
Text File  |  1996-08-18  |  38KB  |  1,685 lines

  1. void() W_SetCurrentAmmo;
  2. /* ALL LIGHTS SHOULD BE 0 1 0 IN COLOR ALL OTHER ITEMS SHOULD
  3. BE .8 .3 .4 IN COLOR */
  4. float useget;
  5. void() barrel_explode;                    //ws...
  6. void() BecomeExplosion;
  7. void() item_destroy =
  8. {
  9.     self.takedamage = DAMAGE_NO;
  10.     sound (self, CHAN_VOICE, "weapons/r_exp3.wav", 1, ATTN_NORM);
  11.     particle (self.origin, '0 0 0', 10, 200);
  12.     self.origin_z = self.origin_z + 32;
  13.     BecomeExplosion ();
  14. };                            //...ws
  15.  
  16. void() SUB_regen =
  17. {
  18.     self.model = self.mdl;        // restore original model
  19.     self.solid = SOLID_BBOX;        // allow it to be touched again
  20.     sound (self, CHAN_VOICE, "items/itembk2.wav", 1, ATTN_NORM);    // play respawn sound
  21.     setorigin (self, self.origin);
  22. };
  23.  
  24. /*QUAKED noclass (0 0 0) (-8 -8 -8) (8 8 8)
  25. prints a warning message when spawned
  26. */
  27. void() noclass =
  28. {
  29.     dprint ("noclass spawned at");
  30.     dprint (vtos(self.origin));
  31.     dprint ("\n");
  32.     remove (self);
  33. };
  34.  
  35. /*
  36. ============
  37. PlaceItem
  38.  
  39. plants the object on the floor
  40. ============
  41. */
  42. void() PlaceItem =
  43. {
  44.     local float    oldz;
  45.  
  46.     self.mdl = self.model;        // so it can be restored on respawn
  47.     self.flags = FL_ITEM;        // make extra wide
  48.     self.solid = SOLID_BBOX;
  49.     self.movetype = MOVETYPE_TOSS;    
  50.     self.velocity = '0 0 0';
  51.     self.origin_z = self.origin_z + 6;
  52.     oldz = self.origin_z;
  53.     self.health = 100;                //ws...
  54.     self.flags = FL_OBJECT;
  55.     if (self.ammo_rockets > 0)
  56.         self.th_die = barrel_explode;
  57.     else self.th_die = item_destroy;
  58.     self.takedamage = DAMAGE_AIM;        //...ws
  59.  
  60.     if (!droptofloor())
  61.     {
  62.         dprint ("Bonus item fell out of level at ");
  63.         dprint (vtos(self.origin));
  64.         dprint ("\n");
  65.         remove(self);
  66.         return;
  67.     }
  68. };
  69.  
  70. /*
  71. ============
  72. StartItem
  73.  
  74. Sets the clipping size and plants the object on the floor
  75. ============
  76. */
  77. void() StartItem =
  78. {
  79.     self.nextthink = time + 0.2;    // items start after other solids
  80.     self.think = PlaceItem;
  81. };
  82.  
  83. /*
  84. =========================================================================
  85.  
  86. HEALTH BOX
  87.  
  88. =========================================================================
  89. */
  90. //
  91. // T_Heal: add health to an entity, limiting health to max_health
  92. // "ignore" will ignore max_health limit
  93. //
  94. float (entity e, float healamount, float ignore) T_Heal =
  95. {
  96.     if (e.health <= 0)
  97.         return 0;
  98.     if ((!ignore) && (e.health >= other.max_health))
  99.         return 0;
  100.     healamount = ceil(healamount);
  101.  
  102.     e.health = e.health + healamount;
  103.     if ((!ignore) && (e.health >= other.max_health))
  104.         e.health = other.max_health;
  105.         
  106.     if (e.health > 250)
  107.         e.health = 250;
  108.     return 1;
  109. };
  110.  
  111. /*QUAKED item_health (.3 .3 1) (0 0 0) (32 32 32) rotten megahealth
  112. Health box. Normally gives 25 points.
  113. Rotten box heals 5-10 points,
  114. megahealth will add 100 health, then 
  115. rot you down to your maximum health limit, 
  116. one point per second.
  117. */
  118.  
  119. float    H_ROTTEN = 1;
  120. float    H_MEGA = 2;
  121. .float    healamount, healtype;
  122. void() health_touch;
  123. void() item_megahealth_rot;
  124.  
  125. void() item_health =
  126. {    
  127.     self.touch = health_touch;
  128.  
  129.     if (self.spawnflags & H_ROTTEN)
  130.     {
  131.         precache_model("maps/b_bh10.bsp");
  132.  
  133.         precache_sound("items/r_item1.wav");
  134.         setmodel(self, "maps/b_bh10.bsp");
  135.         self.noise = "items/r_item1.wav";
  136.         self.healamount = 15;
  137.         self.healtype = 0;
  138.     }
  139.     else
  140.     if (self.spawnflags & H_MEGA)
  141.     {
  142.         precache_model("maps/b_bh100.bsp");
  143.         precache_sound("items/r_item2.wav");
  144.         setmodel(self, "maps/b_bh100.bsp");
  145.         self.noise = "items/r_item2.wav";
  146.         self.healamount = 100;
  147.         self.healtype = 2;
  148.     }
  149.     else
  150.     {
  151.         precache_model("maps/b_bh25.bsp");
  152.         precache_sound("items/health1.wav");
  153.         setmodel(self, "maps/b_bh25.bsp");
  154.         self.noise = "items/health1.wav";
  155.         self.healamount = 25;
  156.         self.healtype = 1;
  157.     }
  158.     setsize (self, '0 0 0', '32 32 56');
  159.  
  160.     StartItem ();
  161. };
  162.  
  163.  
  164. void() health_touch =
  165. {
  166.     local    float amount;
  167.     local    string    s;
  168.     
  169.     if (other.classname != "player")
  170.         return;
  171.     if (other.impulse != 14)        //ws
  172.         return;            //ws
  173.     useget = 0;            //ws
  174.     if (self.healtype == 2) // Megahealth?  Ignore max_health...
  175.     {
  176.         if (other.health >= 250)
  177.             return;
  178.         if (!T_Heal(other, self.healamount, 1))
  179.             return;
  180.     }
  181.     else
  182.     {
  183.         if (!T_Heal(other, self.healamount, 0))
  184.             return;
  185.     }
  186.     
  187.     sprint(other, "You receive ");
  188.     s = ftos(self.healamount);
  189.     sprint(other, s);
  190.     sprint(other, " health\n");
  191.     
  192. // health touch sound
  193.     sound(other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
  194.  
  195.     stuffcmd (other, "bf\n");
  196.     
  197.     self.model = string_null;
  198.     self.solid = SOLID_NOT;
  199.  
  200.     // Megahealth = rot down the player's super health    
  201.     if (self.healtype == 2)
  202.     {
  203.         other.items = other.items | IT_SUPERHEALTH;
  204.         self.nextthink = time + 5;
  205.         self.think = item_megahealth_rot;
  206.         self.owner = other;
  207.     }
  208.     else
  209.     {
  210.         if (deathmatch != 2)        // deathmatch 2 is the silly old rules
  211.         {
  212.             if (deathmatch)
  213.                 self.nextthink = time + 20;
  214.             self.think = SUB_regen;
  215.         }
  216.     }
  217.     
  218.     activator = other;
  219.     SUB_UseTargets();                // fire all targets / killtargets
  220. };    
  221.  
  222. void() item_megahealth_rot =
  223. {
  224.     other = self.owner;
  225.     
  226.     if (other.health > other.max_health)
  227.     {
  228.         other.health = other.health - 1;
  229.         self.nextthink = time + 1;
  230.         return;
  231.     }
  232.  
  233. // it is possible for a player to die and respawn between rots, so don't
  234. // just blindly subtract the flag off
  235.     other.items = other.items - (other.items & IT_SUPERHEALTH);
  236.     
  237.     if (deathmatch == 1)    // deathmatch 2 is silly old rules
  238.     {
  239.         self.nextthink = time + 20;
  240.         self.think = SUB_regen;
  241.     }
  242. };
  243.  
  244. /*
  245. ===============================================================================
  246.  
  247. ARMOR
  248.  
  249. ===============================================================================
  250. */
  251.  
  252. void() armor_touch;
  253.  
  254. void() armor_touch =
  255. {
  256.     local    float    type, value, bit;
  257.     
  258.     if (other.health <= 0)
  259.         return;
  260.     if (other.classname != "player")
  261.         return;
  262.     if (other.impulse != 14)        //ws
  263.         return;            //ws
  264.     useget = 0;            //ws
  265.     if (self.classname == "item_armor1")
  266.     {
  267.         type = 0.3;
  268.         value = 100;
  269.         bit = IT_ARMOR1;
  270.     }
  271.     if (self.classname == "item_armor2")
  272.     {
  273.         type = 0.6;
  274.         value = 150;
  275.         bit = IT_ARMOR2;
  276.     }
  277.     if (self.classname == "item_armorInv")
  278.     {
  279.         type = 0.8;
  280.         value = 200;
  281.         bit = IT_ARMOR3;
  282.     }
  283.     if (other.armortype*other.armorvalue >= type*value)
  284.         return;
  285.         
  286.     other.armortype = type;
  287.     other.armorvalue = value;
  288.     other.items = other.items - (other.items & (IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + bit;
  289.  
  290.     self.solid = SOLID_NOT;
  291.     self.model = string_null;
  292.     if (deathmatch == 1)
  293.         self.nextthink = time + 20;
  294.     self.think = SUB_regen;
  295.  
  296.     sprint(other, "You got armor\n");
  297. // armor touch sound
  298.     sound(other, CHAN_ITEM, "items/armor1.wav", 1, ATTN_NORM);
  299.     stuffcmd (other, "bf\n");
  300.     
  301.     activator = other;
  302.     SUB_UseTargets();                // fire all targets / killtargets
  303. };
  304.  
  305.  
  306. /*QUAKED item_armor1 (0 .5 .8) (-16 -16 0) (16 16 32)
  307. */
  308.  
  309. void() item_armor1 =
  310. {
  311.     self.touch = armor_touch;
  312.     precache_model ("progs/armor.mdl");
  313.     setmodel (self, "progs/armor.mdl");
  314.     self.skin = 0;
  315.     setsize (self, '-16 -16 0', '16 16 56');
  316.     StartItem ();
  317. };
  318.  
  319. /*QUAKED item_armor2 (0 .5 .8) (-16 -16 0) (16 16 32)
  320. */
  321.  
  322. void() item_armor2 =
  323. {
  324.     self.touch = armor_touch;
  325.     precache_model ("progs/armor.mdl");
  326.     setmodel (self, "progs/armor.mdl");
  327.     self.skin = 1;
  328.     setsize (self, '-16 -16 0', '16 16 56');
  329.     StartItem ();
  330. };
  331.  
  332. /*QUAKED item_armorInv (0 .5 .8) (-16 -16 0) (16 16 32)
  333. */
  334.  
  335. void() item_armorInv =
  336. {
  337.     self.touch = armor_touch;
  338.     precache_model ("progs/armor.mdl");
  339.     setmodel (self, "progs/armor.mdl");
  340.     self.skin = 2;
  341.     setsize (self, '-16 -16 0', '16 16 56');
  342.     StartItem ();
  343. };
  344.  
  345. /*
  346. ===============================================================================
  347.  
  348. WEAPONS
  349.  
  350. ===============================================================================
  351. */
  352.  
  353. void() bound_other_ammo =
  354. {
  355.     if (other.ammo_shells > 100)
  356.         other.ammo_shells = 100;
  357.     if (other.ammo_nails > 200)
  358.         other.ammo_nails = 200;
  359.     if (other.ammo_rockets > 100)
  360.         other.ammo_rockets = 100;        
  361.     if (other.ammo_cells > 200)
  362.         other.ammo_cells = 200;        
  363. };
  364.  
  365.  
  366. float(float w) RankForWeapon =
  367. {
  368.     if (w == IT_LIGHTNING)
  369.         return 1;
  370.     if (w == IT_ROCKET_LAUNCHER)
  371.         return 2;
  372.     if (w == IT_SUPER_NAILGUN)
  373.         return 3;
  374.     if (w == IT_GRENADE_LAUNCHER)
  375.         return 4;
  376.     if (w == IT_SUPER_SHOTGUN)
  377.         return 5;
  378.     if (w == IT_NAILGUN)
  379.         return 6;
  380.     return 7;
  381. };
  382.  
  383. /*
  384. =============
  385. Deathmatch_Weapon
  386.  
  387. Deathmatch weapon change rules for picking up a weapon
  388.  
  389. .float        ammo_shells, ammo_nails, ammo_rockets, ammo_cells;
  390. =============
  391. */
  392. void(float old, float new) Deathmatch_Weapon =
  393. {
  394.     local float or, nr